import { number } from 'echarts'
import AddressSelect from './components/AddressSelect/index.vue'
import { personBus } from './personBus.js'

const userMixin = {
  components: {
    AddressSelect
  },
  data() {
    return {
      globalError: false,
      form: {

      },
      dictPositionList: []
    }
  },
  computed: {
    judgeNum() {
      return (vv) => {
        if ((!vv && vv !== 0) || vv < 0) {
          this.globalError = true
          return '该项为必填项'
        }
        if (Number(vv) && vv > 100000000) {
          this.globalError = true

          return '该值小于10000000'
        }
        this.globalError = false
        return null
      }
    },

  },
  watch: {

  },
  mounted() {

  },
  methods: {
    // judgeNum(vv) {
    //   if ((!vv && vv !== 0) || vv < 0) {
    //     this.globalError = true
    //     return '该项为必填项'
    //   }
    //   if (Number(vv) && vv > 100000000) {
    //     this.globalError = true

    //     return '该值小于10000000'
    //   }
    //   return null
    // },
    judgeFillBaseInfo() {
      let name = this.$store.getters.userBaseInfo.companyName
      let nowPath = this.$route.path
      let toPath = '/user/baseInfo'

      if (name) {
        // this.$refs.dialogTip.hideDialog()
        personBus.$emit('changeDialog', false)
        return false
      } else {
        if (nowPath === toPath) {
          personBus.$emit('changeDialog', false)
          return false
        }
        personBus.$emit('changeDialog', true)
        return true
      }
    },
    initDictList() {
      return new Promise((resovle) => {
        this.getDictList('user_common_field').then((res) => {
          if (res.code == 200) {
            this.dictPositionList = res.data
          }
          resovle(res)
        })
      })
    },
    baseInfoToForm() {
      let userBaseInfo = this.$store.getters.userBaseInfo
      if (userBaseInfo) {
        for (const key in userBaseInfo) {
          if (
            Object.hasOwnProperty.call(userBaseInfo, key) &&
            Object.hasOwnProperty.call(this.form, key)
          ) {
            const baseEle = userBaseInfo[key]
            this.form[key] = baseEle
          }
        }
      }
    },

  }
}
export default userMixin
